home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / mac / files / p_msys / msysb116.exe / SCAN440.ASM < prev    next >
Assembly Source File  |  1993-12-05  |  5KB  |  172 lines

  1. ; scan440.asm
  2.  
  3. ;       Here is sample source for a Scan TSR to be used with the MSYS
  4. ;       Pactor scan command
  5.  
  6. ;       This example is for the Kenwood TS-440. It may work for other
  7. ;       Kenwood HF radios without modification. The TS-440 requires 
  8. ;       the following command format:   CCxxxx;
  9. ;       where CC is a two letter command name, xxxx is the parameters
  10. ;       needed for the command and ; is a semicolon which terminates
  11. ;       each command. To set the frequency on the TS-440, I send two
  12. ;       commands: FN0; which tells the radio to use VFO A and the 
  13. ;       the frequency FA00014235000; which is a frequency of 14.235
  14. ;       MHz. Note that the frequency must always be 11 digits for this
  15. ;       radio. 
  16.  
  17. ;       to produce the executable for this program, use the following
  18. ;
  19. ;       asm     scan440.asm     {tasm or masm may be used}
  20. ;       link    scan440;
  21. ;       exe2bin scan440         {makes .com file out of .exe file}
  22.  
  23.  
  24. code    segment
  25.         assume  cs:code,ds:code
  26.  
  27. main    proc    far
  28.         org     0
  29. segorg  equ     $
  30.         org     100h
  31. start:  jmp     install
  32.  
  33.  
  34. port    dw      0               ;control uart base address
  35. ten     dw      10              ;divisor
  36. thousand dw     1000
  37. cmd     db      'FN0;FA'
  38. freq    db      'GGMMMKKKHHH;',0
  39. savequot dw     0
  40.  
  41.  
  42. putser  proc near
  43. ;       send char in AL
  44.         push    dx
  45.         push    ax
  46.         mov     dx,port
  47.         add     dx,5            ;line status register
  48. wait1:  in      al,dx
  49.         and     al,20h          ;check transmit holding reg 
  50.         jz      wait1           ;not ready yet
  51.         pop     ax
  52.         mov     dx,port
  53.         out     dx,al           ;send char to serial port
  54.         pop     dx
  55.         ret
  56. putser  endp
  57.  
  58. putserstr proc near
  59. ;       sends string pointed to by bx 
  60.         push    ax
  61.         push    bx
  62. psloop:
  63.         mov     al, byte ptr [bx]
  64.         cmp     al,0
  65.         je      putserstrexit
  66.         call    putser
  67.         inc     bx
  68.         jmp     psloop
  69. putserstrexit:
  70.         pop     bx
  71.         pop     ax
  72.         ret
  73. putserstr endp
  74.  
  75.  
  76.  
  77. handler:
  78.         STI                     ; enable interrupts
  79. ;                               ; If we don't we will get overruns
  80. ;                               ; on the serial ports for the tnc's
  81.         push    ds              ; save some registers
  82.         push    ax
  83.         push    ax              ; save ax a second time
  84.         mov     ax,cs
  85.         mov     ds,ax           ; set up ds
  86.         pop     ax              ; get back the ax we were called with
  87.  
  88.  
  89. ;
  90. ;       upon entry, dx has port address
  91. ;                   ax has high order part of frequency
  92. ;                   bx has low order part of frequency
  93.         mov     port,dx
  94.  
  95.  
  96. ; div divides DX:AX giving quot in AX, rem in DX
  97.         mov     dx,ax
  98.         mov     ax,bx   
  99. ;       We have a bit of a problem in that the DIV instruction 
  100. ;       requires that the quotient will fit in a 16 bit register.
  101. ;       But a frequency like 14.350, which is 14350000 in the 
  102. ;       long (32 bit) variable and when divided by 10 the 
  103. ;       quotient won't fit in 16 bits (AX). 
  104. ;
  105. ;       So here is what we will do...
  106. ;       First divide the original frequency by 1000. This will
  107. ;       give a quotient <= 30000 which will fit.
  108. ;       The remainder from this division will be run thru the
  109. ;       divide by 10 to get the digits loop three times.
  110. ;       Then we take the quotient and use the same instructions
  111. ;       to do the other 8 required digits
  112.  
  113.         div     thousand        ;rem in dx, quot in ax
  114.         mov     savequot,ax
  115.         mov     ax,dx           ;set up for divide
  116.         sub     dx,dx
  117.         
  118.         mov     cx,3                    ;number of digits
  119.         mov     bx,offset freq+10       ;place for first
  120.  
  121. dloop1:
  122.         div     ten
  123.         add     dl,'0'                  ;convert to ascii
  124.         mov     byte ptr [bx],dl
  125.         sub     dx,dx
  126.         dec     bx
  127.         dec     cx
  128.         cmp     cx,0
  129.         jne     dloop1
  130.         
  131.         mov     ax,savequot
  132.         sub     dx,dx
  133.         mov     cx,8
  134. dloop2:
  135.         div     ten
  136.         add     dl,'0'                  ;convert to ascii
  137.         mov     byte ptr [bx],dl
  138.         sub     dx,dx
  139.         dec     bx
  140.         dec     cx
  141.         cmp     cx,0
  142.         jne     dloop2
  143.  
  144. xxx:
  145.  
  146.         mov     bx,offset cmd
  147.         call    putserstr
  148.  
  149.         pop     ax
  150.         pop     ds
  151.         iret
  152. main    endp
  153.  
  154.  
  155. install:
  156.         mov     dx,offset msg1
  157.         mov     ah,9
  158.         int     21h
  159.         mov     dx,offset handler
  160.         mov     al,0D2h
  161.         mov     ah,25h
  162.         int     21h
  163.  
  164.         mov     dx,(offset install - segorg +15) shr 4
  165.         mov     ah,31h
  166.         int     21h
  167.  
  168. msg1    db      'Scan TSR loaded for Kenwood TS-440 using Int D2',13,10,'$'
  169.  
  170. code    ends
  171.         end     start
  172.